import torch
pre = torch.tensor([1.1,2.2])
label = torch.tensor([0.,1.0])
#l1  损失函数
l1loss = torch.nn.L1Loss(False)
print('l1loss',l1loss(pre,label))

#MSE均值损失函数
mse = torch.nn.MSELoss(size_average=False)
print('mse loss:',mse(pre.sum(),label.sum()))

#交叉熵
criterion = torch.nn.CrossEntropyLoss()
print('cross entropy:',criterion(pre,label))